package me.firstapp.module.shop;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import me.firstapp.module.base.CommonEntity;
import me.firstapp.module.bbs.Member;

@Entity
@Table(name = "SHOPPING_CART")
public class ShoppingCart extends CommonEntity {

	private static final long serialVersionUID = 5981457974044323762L;

	// 关联的用户
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MEMBER_ID", referencedColumnName = "ID", unique = true, nullable = false)
	private Member member;

	// 商品总数量
	@Column(name = "COUNTS", nullable = false)
	private Integer counts;

	// 商品总价
	@Column(name = "VALUE", columnDefinition = "DECIMAL(11, 2)", nullable = false)
	private Double value;

	@Transient
	private List<ShoppingCartItem> items = new ArrayList<>();

	public List<ShoppingCartItem> getItems() {
		return items;
	}

	public void setItems(List<ShoppingCartItem> items) {
		this.items = items;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public Integer getCounts() {
		return counts;
	}

	public void setCounts(Integer counts) {
		this.counts = counts;
	}

	public Double getValue() {
		return value;
	}

	public void setValue(Double value) {
		this.value = value;
	}

}
